<?php
namespace Crm\Api;

use PhalApi\Api;
use PhalApi\Request;
use PhalApi\Exception\BadRequestException;
use Auth\Api\Token as Token;
use Crm\Domain\Total as DomainTotal;

/**
 * 统计服务类
 *
 * @author: dogstar <751450467@qq.com> 2014-10-04
 */

class Total extends Api {

    /**
     * token对象
     */
    public $token;

    /**
     * 当前用户信息
     */
    public $user;

    public function __construct()
    {
        //允许所有域名发起的跨域请求
        header('Access-Control-Allow-Origin: *');  //支持全域名访问，不安全，部署后需要固定限制为客户端网址
        //header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); //支持的http 动作
        //header('Access-Control-Allow-Headers:Authorization,content-type');  //响应头 请按照自己需求添加。
        //$this->di = \PhalApi\DI();
        $this->token = new Token();

    }

	public function getRules() {
        return array(
            'todayPerson' => array(),
        );
	}
	
	/**
	 * 个人消息统计
     * @desc 个人消息统计，今日个人相关信息统计
	 * @return obj array 统计列表
	 * @return int time 当前时间戳
	 */
	public function todayPerson() {
        $this->user = $this->token->checkToken();

        $domain = new DomainTotal();
        $rs = $domain->todayPerson($this->user);
        return $rs;
	}


}
